#!/usr/bin/env bash

repo=registry.cn-hangzhou.aliyuncs.com
version=v1.4.7
projects=(ingress-controller ingress-agent ingress-gateway)
source=zhouyi
targets=(wise2c-dev wise2c-test)

for project in ${projects[*]}
do
    source_image=${repo}/${source}/${project}:${version}
    echo "pull ${source_image}"
    docker pull ${source_image}

    for target in ${targets[*]}
    do
        target_image=${repo}/${target}/${project}:${version}
        echo "push ${target_image}"
        docker tag ${source_image} ${target_image}
        docker push ${target_image}

        # for stable.
        if [[ x"${project}" == x"ingress-gateway" ]]; then
            target_image=${repo}/${target}/${project}:stable
            echo "push ${target_image}"
            docker tag ${source_image} ${target_image}
            docker push ${target_image}
        fi
    done
done